#include "StdAfx.h"
#include "InputLayouts.h"
#include "Effects.h"



ID3D10InputLayout *InputLayout::PosNormalTex = 0;
ID3D10InputLayout *InputLayout::Pos = 0;

void InputLayout::InitAll(ID3D10Device *device)
{
    D3D10_PASS_DESC PassDesc;

	// Create the vertex input layout.
	D3D10_INPUT_ELEMENT_DESC vertexDesc[] =
	{
		{"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0},
		{"NORMAL",	 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D10_INPUT_PER_VERTEX_DATA, 0},
		{"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D10_INPUT_PER_VERTEX_DATA, 0}
	};

	// Create the input layout
	ZeroMemory( &PassDesc, sizeof(PassDesc) );
	fx::WaveFX->GetTechniqueByName("WaveTech")->GetPassByIndex(0)->GetDesc(&PassDesc);
    HR( device->CreateInputLayout(vertexDesc, _countof(vertexDesc), PassDesc.pIAInputSignature,
		PassDesc.IAInputSignatureSize, &PosNormalTex) );

	// Sky Vertex
	D3D10_INPUT_ELEMENT_DESC skyVertexDesc[] =
	{
		{"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0}
	};
	ZeroMemory( &PassDesc, sizeof(PassDesc) );
	fx::SkyFX->GetTechniqueByName("SkyTech")->GetPassByIndex(0)->GetDesc(&PassDesc);
	HR( device->CreateInputLayout(skyVertexDesc, _countof(skyVertexDesc), PassDesc.pIAInputSignature,
		PassDesc.IAInputSignatureSize, &Pos) );
}

void InputLayout::DestroyAll()
{
	ReleaseCOM(PosNormalTex);
}
